package test.ThreadTest;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @Author duWenJian
 * @Date 2024/2/19 13:26
 * @Version 1.0
 */
public class demo01 {

    public static void main(String[] args) {
        MyThread myThread = new MyThread();
        FutureTask<Integer> task = new FutureTask<>(myThread);
        new Thread(task).start();
        try {
            System.out.println(task.get());
        } catch (InterruptedException | ExecutionException e) {
            e.printStackTrace();
        }
    }


    static class MyThread implements Callable<Integer> {
        @Override
        public Integer call() throws Exception {
            return 15;
        }
    }

}
